package com.zzptc.fatetk

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

class MainActivity : AppCompatActivity() {
    interface SearchService{
        @FormUrlEncoded
        @POST("Interface/UserLine/search")
        fun getAllSearch(@Field("pos") pos:Int):Call<SearchData>
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        //JavaClassNew.f3()
        //SearchData("r",7, listOf())
        var retrofit = Retrofit.Builder()
            .baseUrl("http://hh1.me:5001/")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
        val searchService = retrofit.create(SearchService::class.java)
        var call = searchService.getAllSearch(1)
        call.enqueue(object :Callback<SearchData>{
            override fun onFailure(call: Call<SearchData>, t:Throwable){

            }
            override fun onResponse(call: Call<SearchData>, response:Response<SearchData>){
                tv_text.text = response.body()?.message
            }
        })

    }

    fun f1(){

    }
}
